home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
elec_eng
/
eepddsk8.lzh
/
PBAS.DOC
< prev
next >
Wrap
Text File
|
1986-08-30
|
11KB
|
226 lines
PBAS, or "PROCESS a BASIC PROGRAM"
PBAS.BAS, put together by: Tom Story
Lawrence Livermore Lab
Livermore, CA 94550
This program is a concatenation of two very useful public domain programs:
SQUISH.BAS and XREFBUZZ.BAS whose documentation appears below in the
original with appended comments. Numerous bugs were repaired and also
many cosmetic changes were made to both programs.
As far as I can tell, the SQUISH portion functions as advertised. The XREFBUZZ
or cross-reference portion does not leave out any references. However it does
add erroneous references. Specifically, it prints Hex and Octal numbers as line
numbers; and it prints "D" and "E" exponents as variables. Also the bytes
information at the end of the table occasionally prints negative numbers (I
think for larger programs only?). A look at the program listing will also
reveal the possibility for future BASIC version reserved words to be listed
as variables unless they are added to the "DATA" block.
Again, as far as I can tell no references are ommitted so the above bugs
are merely a nuisance and I'm sure myself or someone will resolve them
eventually.
In using PBAS, ignore the operating instructions in the original documentation
below and follow the menus in PBAS. Also, as I have modified the programs
I have renamed them SQUASH.BAS and XREFBAS.BAS so as to distinguish them
from the unmodified source codes.
SQUASH portion:
"Squish" is a utility program for the IBM PC with 32K,
color/graphics adapter, 1 disk drive, and Basic.
(The following is condensed from SoftSide magazine, issue no. 34.):
Programmers tend to use quite a few REMarks when
programming, add extra spaces to make listings more readable, as
well as putting only a few statements on each line. The result
is a program that is easier to read and debug, but not very space
or memory efficient. The ideal utility would remove extra spaces
and REMs, and combine lines, when possible without altering the
structure of the BASIC program.
Enter the TRS-80 program Squish...if only it were translated
to the IBM PC. We've done so, and it is presented here for the
benefit of all our IBM subscribers.
TO USE SQUISH:
First LOAD the program you wish to pack. After it is
loaded, SAVE it with the ASCII option to a new file. For example:
LOAD "MYPROG.BAS" and then reSAVE it as "MYPROG.ASC",A. After
the program has been saved with the ASCII option, LOAD in
"Squish" and type RUN.
Answer the first question with the name of the file saved
with the ASCII option ("MYPROG.ASC" in the example above).
You will then be given a series of options. You can remove
extra spaces, delete REMarks, and combine lines. The fourth
option gives you the ability to protect a line or group of lines
from being "Squished." Lines entered under this option are
totally ignored by "Squish."
"Squish" will then read in the program to check for lines
that are referenced and proceed to work on it. The display will
update constantly to show, in color (or monochrome), what
"Squish" is doing, and where.
When "Squish" is done, it will allow you to enter the
"Squished" program for examination. I suggest you then do a
quick RENUMber and reSAVE the program under another filename.
When you are finished, you will have a neatly renumbered
program that is not only much shorter than the original (usually
by a few K), but will execute faster. All in all, "Squish" is
quite a useful utility.
VARIABLES;
A: Temporary numeric storage.
A$: Current program line being Squished.
AZ: Screen line on which current program line is displayed.
C$: Contains lines that have been combined.
D: Length of a reserved word being searched for.
DS: The maximum number of user protected lines.
DT: Set to 1 if current line contains a DATA statement.
G1 - G6: A position in A$ at which INSTR starts searching.
HH: Miscellaneous.
I$: Name of a DEF FN to convert a string input into a single upper
case letter.
IP$: Set to "Y" if REM statements are to be deleted.
J$: Storage for A$ as it is being reconstructed.
LN: Current line number being processed.
L$, L1$: Current character of A$ being processed.
N$: Set to STR$(LN).
P: Set to 1 the first time a quote is encountered in a PRINT
statement. Set to 0 when second quote or end of
line is encountered. While P equals 1, all
compression functions are cancelled.
PJ: Points to the current line in PRO(*) being tested.
PP: Set to 1 minus the location of the first character in a
program line following the line number.
PV: Number of protected lines entered.
PRO(*): Optional protected line numbers specified by user.
Q$: Used in an INKEY$ loop.
R: Number of line numbers referenced in REF(*).
RD: Total number of REM statements deleted.
RE: Total number of lines combined.
REF(*): Number of program lines that can be referenced.
S,S1: Miscellaneous. Used in sort routine.
SD: Total number of spaces deleted.
SQ$: SAVE filename for Squished program.
SV$: SAVE filename for Squished program.
T,T1-T2: Miscellaneous.
V$: The current program line stripped of its line number.
X: Set equal to PP.
XC$: Set to "Y" if lines are to be combined.
XS$: Set to "Y" if extra spaces are to be deleted.
XP$: Set to "Y" if user wishes to protect lines.
ZC: Position on line AZ to print L$.
2/9/83 Patches, enhancements, etc. by Herb Shear
The R pointer can no longer lag behind allowing referenced REM and '
statements to be deleted.
Trailing ' no longer added on nonnull referenced lines.
RESTORE & RETURN references to a line now protect the line.
Constructs like X=IGOTO+35 no longer protects line 35.
Indentation was preserved even when combining.
The deblanking tests were extended to close up constructs such as
A( I ), etc.
Goofs in naming the input file are now handled in a friendly fashion
instead of repeating the entire input session over again.
3/02/86 Bugs found, by Tom Story.
Program as distributed does not work, found bugs in the following lines:
170 thru 190, 210, 220, 290, 400, 500, and 560. Lines 185 and 560 had multiple
bugs. The function for returning line numbers in line 290 was changed as VAL
returns the wrong number when a "D" or "E" follows the line number.
Dimensioning was modified slightly to accomodate the IBM Basic Compiler.
A function was added to strip out line numbers for the Basic Compiler /N option.
These bugs were corrected, several cosmetic changes were made, the program
renumbered, and renamed SQUISH2.BAS. Probably more bugs lurking.
Users should take note of the instructions to use SAVE"-----",A
files as input. Squish is tuned to the interpreter's output which is a
subset of valid input forms. Lowercase, blanks preceding line numbers
and `GO TO xxx' are not handled properly by Squish.
XREFBAS portion:
This program reads a BASIC program, saved in ASCII
format by using the ",A" option of BASIC, and prepares either a
neat listing, a cross-reference list, or both. The
cross-reference list shows, for each symbol and each referenced
line number, the line numbers in which they occur. This is a
highly valuable aid to debugging. It assists the user in
finding inadvertent uses of the same variable name for two
different purposes, or of different variable names where the
same one was intended, and in locating the source of improper
branches.
The program was contributed to the BPC by Jeff
Friedhoffer, and has been revised by Jim Fennessey. It was
originally published in the June 1981 issue of Interface Age
magazine, and was adapted to the IBM PC by Steve Nossen. This
program may not be sold and may not be used for commercial
gain.
The program asks for filespecs of BASIC programs to be
processed. Up to 9 separate programs may be processed in a
single run of XREF1. The programs to be processed should have
been previously saved using the ",A" option to produce an ASCII
file, and should be resident in one of the disk drives. The
output specification defaults as the printer, but may also be
the communication port or a disk drive. It is generally most
convenient to ask for the output to be sent to a disk, using
the same name as the original program, and the extension
".XRF". Then, once the XREF1 program has finished, you may use
the DOS COPY command to copy filname.XRF to the printer.
XREF1 provides an ongoing indication of its progress
through the program files, and sounds a distinctive tone when
it finishes. Thus, it may be left running unattended if
desired.
One feature worth noting is that if XREF1 encounters a
line in the input program which ends in the characters 'PG
then it will begin a new page of the output listing with that
line of the input program. Thus, if your input program has
several major sections, you can arrange it so that XREF1 starts
each new major section on a new page.
This Cross reference pgm came from the Baltimore PC Users Group
Diskette offering.
PROGRAM NAME: XREF.EXE
AUTHOR:V1.1 Steve Nossen, V1.2 Buzz Hamilton Boston User's Group
ABSTRACT: This is a compiled and corrected version of one of the BASIC
cross reference listing generators found on one of our earlier disks.
Users of any of those earlier programs should abandon them, and use this
one. Buzz Hamilton has heavily modified and corrected the best of the
original three, and then the program was compiled for a drastic increase
in it's operating speed. Cross reference listings are useful
when you are debugging or documenting programs - the locations of all
references to variable names or line numbers are listed in an easy to read
format.
REQUIRES: IBM PC with BASIC language. A printer is extremely helpful but
not strickly necessary.
INSTRUCTIONS: First, this program must reside on a disk which contains
your system COMMAND.COM. Second, the program for which you desire a cross
reference listing must have been saved on disk in ASCII form (,A option).
Then from DOS, type XREFBUZZ<cr> and answer the questions about file names etc.
6/27/86 Bugs found, by Tom Story.
1). Added BASIC 3.0 reserved words.
2). Added references by RESTORE and RETURN.
3). Corrected CSNC to CSNG as reserved word.
4). Fixed problem with reserved word embedded in a variable name.